function deleteMessage() {
	if (deleteconfirm) { 
		updateRequest('','remove',"message_list_form");
	}	
}

function startEditMessage(id,team,start, end) {
	var forma = document.getElementById("message_admin_form");
	var msg = document.getElementById("m"+id).innerHTML;
	forma.id.value=id;
	forma.op.value='edit';
	forma.teamid.value=team;
	forma.message.value=msg;
	
	forma.showstart.value = start;
	forma.showend.value = end;
	
	document.getElementById("message_edit_form").style.display = '';
	document.getElementById("message_add_form").style.display = 'none';
}

function cancelEditMessage() {
	var forma = document.getElementById("message_admin_form");
	forma.op.value='add';
	forma.id.value='';
	forma.teamid.value='0';
	forma.message.value='';
	forma.showstart.value='';
	forma.showend.value='';
	document.getElementById("message_edit_form").style.display = 'none';
	document.getElementById("message_add_form").style.display = '';
}

function validateMessage(form) {
	var forma = document.getElementById(form);
	var valid=true;

	var el = getDateFromString(forma.showstart.value,shortDateFormat);
	var desde=new Date();
	desde.setFullYear(el.year,el.month,el.day);

	el = getDateFromString(forma.showend.value,shortDateFormat);
	var hasta=new Date();
	hasta.setFullYear(el.year,el.month,el.day);
	
	if (hasta<=desde) {
		valid=false;
		alert(invalidDateMessage);
	} else if (forma.message.value=='') {
		valid=false;
		alert(messageMissingMessage);
	}
	if (valid) doProcess(form);

}

function showMessage(e,id) {
	messagewindow = new Poat({dialog: false});
	messagewindow.event = e;
	messagewindow.result = document.getElementById("m"+id).innerHTML;
	messagewindow.name = "message_display_window";
	messagewindow.response("");
}

function html_entity_decode( string ) {
    // http://kevin.vanzonneveld.net
    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
 
    var ret, tarea = document.createElement('textarea');
    tarea.innerHTML = string;
    ret = tarea.value;
    return ret;
}